package hot100;

import java.util.ArrayList;
import java.util.List;

public class subsets2 {
    List<List<Integer>> ret;
    List<Integer> path;

    public List<List<Integer>> subsets(int[] nums) {
        ret = new ArrayList<>();
        path = new ArrayList<>();
        dfs(nums,0);
        return ret;
    }

    void dfs(int[] nums,int i) {
        if(i == nums.length) {
            ret.add(new ArrayList<>(path));
            return;
        }

        path.add(nums[i]);
        dfs(nums,i + 1);
        path.remove(path.size() - 1);
        dfs(nums,i + 1);
    }
}
